<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>app有效性分析</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<!--<link rel="stylesheet" type="text/css" href="../bootstrap/dist/css/bootstrap.min.css"/>-->
		<link rel="stylesheet" type="text/css" href="../bootstrap/dist/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="../new_css/bootstrap-datetimepicker.min.css" />
		<!--<link rel="stylesheet" type="text/css" href="css/public.css" />-->
	</head>
	<style type="text/css">
		.remove {
			cursor: pointer;
		}
		
		.remove:hover {
			color: red;
		}
		
		.pagination span {
			font: 14px/34px "";
			padding: 0 5px;
		}
		
		.form-control {
			display: inline-block;
			width: 150px;
		}
		
		.search {
			width: 155px;
		}
		
		.header {
			/*border-bottom: 1px solid #fefefe;*/
		}
		
		.header span {
			padding: 0 5px;
		}
		
		.table_cla {
			height: 560px;
		}
	</style>

	<body>
		<div id="app" style="width: 100%; margin: 0 auto;padding:0 20px;">
			<div class="header" style="margin-top: 20px;">
				<button type="button"   class="btn btn-info" data-toggle="modal" data-target="#myModal_area">选择小区</button>
				<!--<button type="button" class="btn btn-info " data-dismiss="modal" @click="search('')">搜索</button>-->
			</div>
			<div class="table_cla">
				<table class="table">
					<caption>小区app用户列表</caption>
					<thead>
						<tr>
							<th>小区名</th>
							<th>app用户数</th>
							<th>app有效用户数</th>
							<th>app缴费人数</th>
							<th>有效用户数占比</th>
							<th>缴费人数占比</th>
						</tr>
					</thead>
					<tbody>
						<tr v-for="(tt,index) in table">
							<td v-text="tt.areaname"></td>
							<td v-text="tt.count"></td>
							<td v-text="tt.count1"></td>
							<td v-text="tt.count2"></td>
							<td v-text="tt.result"></td>
							<td v-text="tt.result1"></td>
						</tr>
					</tbody>
				</table>

			</div>
			<!--<ul class="pagination">
				<span v-text="count_all"></span>				
				<li v-for="index in pages" @click="goto(index)" :class="{'active':current == index}" :key="index">
					<a href="#" v-text="index"></a>
				</li>				
				<span>跳到:</span>				
				<input style="width: 50px;height: 28px;" name="goto" id="goto" v-model="jump" type="text" name="" oninput="value=value.replace(/[^\d]/g,'')">
				<span>页</span>
				<button type="button" id="gotoo" @click="goto(jump)" class="btn btn-danger ">确定 </button>
			</ul>-->
			<!-- 模态框（Modal）选择小区-->
			<div class="modal fade" id="myModal_area" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title" id="myModalLabel">选择小区</h4>
						</div>
						<div class="modal-body">
							<!--<p style="color: red;display: block;text-align: center;">建议小区数量尽量在10个以下，否则可能造成显示效果不佳</p>-->
							<label class="checkbox-inline" v-for="item in area">
						      <input type="checkbox" :value="item.areaid" v-model="area_list">{{item.areaname}}
						    </label>
						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
							<button type="button" class="btn btn-success" id="search_text"  @click="sure_area">确定</button>
						</div>
					</div>
				</div>
			</div>
			<!-- 模态框（Modal）提示信息 -->
			<div class="modal fade" id="myModal_tips" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title" id="myModalLabel">提示信息</h4>
						</div>
						<div class="modal-body" id="tips" v-text="tips_modal">

						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						</div>
					</div>
				</div>
			</div>
		</div>

	</body>

</html>
<script src="../new_js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../new_js/vue.js" type="text/javascript" charset="utf-8"></script>
<script src="../bootstrap/dist/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../new_js/bootstrap-datetimepicker.js" type="text/javascript" charset="utf-8"></script>
<script src="../new_js/bootstrap-datetimepicker.zh-CN.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/public.js" type="text/javascript" charset="utf-8"></script>
<script>
	new Vue({
		el: '#app',
		data: {
			val_te: "",
			urltest: "",
			userId: "",
			current: 1,
			fullname: "",
			showItem: 5,
			allpage: "",
			userName: "",
			jump: "",
			page_show: false,
			tips_modal: "",
			count_all: "",
			areaid: "",
			start: "",
			end: "",
			searchmain: "",
			panduan: "",
			merchantid: "",

			leixing_model: "",
			removeid: "",
			area: [],
			area_list:[],
			area_model: "",
			table: [{
			},
			]
		},
		//计算属性
		computed: {

		},
		created: function() {

		},
		mounted: function() {
			var that = this;
			var userId = sessionStorage.getItem("userId");

			if(userId == "" || userId == undefined || userId == null) {
				top.location.href = "../login.html";
			} else {
				that.urltest = sessionStorage.getItem("urltest");
				that.userId = sessionStorage.getItem("userId");
				that.fullname = sessionStorage.getItem("fullname");
				that.userName = sessionStorage.getItem("userName");	
				that.area_info()
			}
		},
		computed: {
			pages: function() {
				var pag = [];
				if(this.current < this.showItem) { //如果当前的激活的项 小于要显示的条数
					//总页数和要显示的条数那个大就显示多少条
					var i = Math.min(this.showItem, this.allpage);
					while(i) {
						pag.unshift(i--);
					}
				} else { //当前页数大于显示页数了
					var middle = this.current - Math.floor(this.showItem / 2), //从哪里开始
						i = this.showItem;
					if(middle > (this.allpage - this.showItem)) {
						middle = (this.allpage - this.showItem) + 1
					}
					while(i--) {
						pag.push(middle++);
					}
				}
				return pag
			},

		},
		methods: {
			//获取小区			
			area_info: function() {
				var that = this;
				var data = JSON.stringify({
					requestString: '',
					userId: that.userId,
					fullname: that.fullname
				});		
				$.ajax({
					contentType: "application/json; charset=utf-8",
					type: "POST",
					url: that.urltest + "/verify/financial/selectAreaNameList",
					data: data,
					async: true,
					dataType: "json",
					success: function(msg) {
						if(msg.responseCode == 200) {
							var aa = JSON.parse(msg.returnString);
							that.area = aa;
						} else {
							//							alert(msg.disp)
							that.tips_modal = msg.resoponseDisp;
							$('#myModal_tips').modal('show');
						}
					},
					error: function() {
						//						alert("获取信息失败");
						that.tips_modal = "获取信息失败";
						$('#myModal_tips').modal('show');
					}
				});
			},
			
			search: function() {				
				var that = this;				
					var data = JSON.stringify({
						requestString: JSON.stringify({
							areaidlist: that.area_list,							
						}),
						userId: that.userId,
						fullname: that.fullname
					});
				$.ajax({
					contentType: "application/json; charset=utf-8",
					type: "POST",
					url: that.urltest + "/verify/financial/analysisForApp",
					data: data,
					async: true,
					dataType: "json",
					success: function(msg) {
						$("#myModal_area").modal('hide')
						$("#search_text").attr('disabled', false);
						$('#search_text').html('确定');	
						if(msg.responseCode == 200) {
							that.table = JSON.parse(msg.returnString);	
							if(msgg.length==0){
								that.tips_modal = "暂无数据";
								$('#myModal_tips').modal('show');
							}
							var yu = msg.count % 10;
							if(yu == 0) {
								that.allpage = parseInt(msg.count / 10);
							} else {
								that.allpage = parseInt(msg.count / 10) + 1;
							}
							that.count_all = "共" + msg.count + "条 "+ " 共" + that.allpage + "页";
						} else {							
							that.tips_modal = msg.resoponseDisp;
							$('#myModal_tips').modal('show');
						}
					},
					error: function() {
						$("#search_text").attr('disabled', false);
						$('#search_text').html('确定');	
						$("#myModal_area").modal('hide')
						that.tips_modal = "获取信息失败";
						$('#myModal_tips').modal('show');
					}
				});

			},
			
			//sure_area 确定所选小区
			sure_area: function() {
				//				console.log(this.area_list)
				this.search();
			}

		},

	})
</script>